<?php
/**
 * Created by PhpStorm.
 * User: gzc0918
 * Date: 2021-08-08
 * Time: 18:05
 */

namespace IMooc;


abstract class EventGenerator
{
    private $observers = array();

    //增加观察者
    function addObserver(Observer $observer)
    {
        $this->observers[] = $observer;
    }

    //通知，事件已经发生了，其他观察者可以进行更新操作了
    function notify(){
        foreach ($this->observers as $observer){
            $observer->update();
        }
    }
}